import dash
import feffery_antd_components as fac
from dash import html
from dash.dependencies import Input, Output

from server import app

layout = html.Div(
    [
        fac.AntdSpace(
            fac.AntdEmpty(),
            id='tab1-container-demo'
        ),
        fac.AntdDivider(isDashed=True),
        fac.AntdButton(
            '生成回调用组件',
            id='generate-above-widgets',
            type='primary'
        )
    ]
)


@app.callback(
    Output('tab1-demo-output', 'children'),
    Input('tab1-demo-button', 'nClicks')
)
def tab1_callback_demo(nClicks):
    if nClicks:
        return nClicks

    return dash.no_update


@app.callback(
    Output('tab1-container-demo', 'children'),
    Input('generate-above-widgets', 'nClicks')
)
def tab1_generate_widgets(nClicks):
    if nClicks:
        return [
            fac.AntdButton(
                'tab1示例按钮',
                id='tab1-demo-button',
                type='primary'
            ),
            fac.AntdText(id='tab1-demo-output')
        ]

    return dash.no_update
